<template>
  <div>
    <user-bar :modalType='modalType' :getList='getList'></user-bar>
    <bussiness-home 
      :modalType='modalType' 
      v-if='$route.params.userId === "business"' 
      @editBtn = 'editBtn'
      :bussinessInfo = 'bussinessInfo'
      :getList="getList"
      :identifyType='identifyType'
      ></bussiness-home>

    <customerHome v-else :identifyType='identifyType'>你好</customerHome>
  </div>
</template>

<script>

import UserBar from './useritem/UserBar.vue'
import bussinessHome from './business/bussinessHome.vue'
import customerHome from './customer/customerHome.vue'

import {getUser} from '@/network/user'

export default {
  name:'userHome',
  data() {
    return {
      bussinessInfo:[],
      modalType:0, // 0表示新增，1表示编辑的弹窗
      currentrow:{},
      identifyType : 0 , //0表示顾客，1表示商家
    }
  },
  components:{
    UserBar,
    bussinessHome,
    customerHome
  },
  created() {
    console.log(this.$route.params.userId);
    this.getList() 
  },
  computed:{
    // business(){
    //   return ;
    // }
  },
   methods: {
    getList(){
       getUser().then(({data}) =>{          
          console.log('***********获取用户信息********');
          console.log('@',data.data);
          if(data.data.status === 200){
             
              this.bussinessInfo = data.data.result
          }
        })
    },
    mounted() {
      getList()
    },
    editBtn(row){
      console.log('我是接受子组件的row',row);
      this.currentrow = row
      this.modalType = 1
    }
    // getUser(){
    //   getUser().then(res=>{
        
    //     console.log(res.data.data);
    //     let result = res.data.data
    //     console.log(result);
    //     if(result.status === 200) {
    //       this.bussinessInfo = result.result
    //     }
    //     console.log(this.bussinessInfo);
    //     // console.log(this.bussinessInfo);
    //   })
      
    // }
  },
}
</script>

<style>

</style>